<?php
require_once APPLICATION_PATH.'/utils/SessionManager.class.php';

abstract class AbstractBaseController extends Zend_Controller_Action
{
    private $sessionManager;

    public function __construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs = array())
    {
        parent::__construct($request, $response, $invokeArgs);
    }

    protected function isParameterSet($paramName)
    {
        return isset($_REQUEST[$paramName]);
    }

    protected function getRequestParameter($paramName, $isMandatory=false)
    {
        if (!isset($_REQUEST[$paramName]))
        {
            if ($isMandatory)
            {
                throw new Exception('Mandatory parameter not set: '.$paramName);
            }
        }
        else
        {
            return $_REQUEST[$paramName];
        }
    }

    protected function disableLayout()
    {
        $this->_helper->layout()->disableLayout();
        $this->_helper->viewRenderer->setNoRender(true);
    }

    protected function getSessionManager()
    {
        if (!isset($this->sessionManager))
        {
            $this->sessionManager = new SessionManager();
        }

        return $this->sessionManager;
    }
}